/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.bookshop.customControllers;

import com.bookshop.entity.Category;
import com.bookshop.facade.CategoryFacade;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

/**
 *
 * @author Thibault
 */
@ManagedBean(name = "myCategoryController")
@SessionScoped
public class myCategoryController implements Serializable {
    
    @EJB
    private CategoryFacade categoryFacade;
    private List<Category> categories = new ArrayList<Category>();
    private Category category = new Category();

    public List<Category> getCategories() {
        if (this.categories.size() == 0) {
            this.categories = categoryFacade.findAll();
        }

        return this.categories;
    }

    public void setCategories(List<Category> categories) {
        this.categories = categories;
    }

    public Category getCategory() {
        return category;
    }

    public void setCategory(Category category) {
        this.category = category;
    }

    /**
     * Creates a new instance of myCategoryController
     */
    public myCategoryController() {
        
    }

}
